import { Component, Input, OnInit, OnDestroy, ViewContainerRef } from '@angular/core';
import { Store } from '@ngrx/store';
import { TranslateService } from 'ng2-translate'; // import translate service
import { AppState } from './interfaces';
import { getAuthStatus } from './auth/reducers/selectors';
import { ToastsManager } from 'ng2-toastr';


@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent  implements OnInit, OnDestroy{
  title = 'app';
  //@Input() isAuthenticated: boolean;
  getLangs: any[];
  constructor(
    private store:  Store<AppState>,
    // private translate: TranslateService
    public  toasrt: ToastsManager,
    public  vcr:    ViewContainerRef
  ) {
    this.toasrt.setRootViewContainerRef(vcr);
  }

  ngOnInit() {
    
    //this.store.select(getAuthStatus);
    // this.getLangs = [
    //   {label: '中文', value: 'zh-CN'},
    //   {label: '英语', value: 'en'}
    // ];
    //
    // this.translate.addLangs(['zh-CN', 'en']);
    // this.translate.setDefaultLang('zh-CN');
    // let broswerLang = this.translate.getBrowserLang();
    // this.translate.use(broswerLang.match(/en|zh-CN/) ? broswerLang : 'zh-CN');
  }

  // changeLang(index) {
  //   this.translate.use(index);
  // }

  ngOnDestroy() {
    //Called once, before the instance is destroyed.
    //Add 'implements OnDestroy' to the class.

  }
}
